package com.cnboy.security.controller;

import com.cnboy.security.domain.ResponseResult;
import com.cnboy.security.domain.User;
import com.cnboy.security.service.loginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class loginController {
    @Autowired
    private loginService loginservice;

    @PostMapping("/user/login")
    public ResponseResult login(@RequestParam("username") String username,@RequestParam("password") String password){
        //登录
        User user = new User();
        user.setUserName(username);
        user.setPassword(password);
        return loginservice.login(user);
    }

    @GetMapping("/user/logout")
    public ResponseResult logout(){
        //退出
        return loginservice.logout();
    }
}
